<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: FormsController
  
    &mdash; Documentation by YARD 0.7.3
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (F)</a> &raquo; 
    
    
    <span class="title">FormsController</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: FormsController
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName"><span class='object_link'><a href="ApplicationController.html" title="ApplicationController (class)">ApplicationController</a></span></span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">ActionController::Base</li>
          
            <li class="next"><span class='object_link'><a href="ApplicationController.html" title="ApplicationController (class)">ApplicationController</a></span></li>
          
            <li class="next">FormsController</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">app/controllers/forms_controller.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>
ELMO - Secure, robust, and versatile data collection. Copyright 2011 The
Carter Center
</p>
<p>
ELMO is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
</p>
<p>
ELMO is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
</p>
<p>
You should have received a copy of the GNU General Public License along
with ELMO. If not, see &lt;http://www.gnu.org/licenses/&gt;.
</p>


  </div>
</div>
<div class="tags">
  

</div>

  
  
  
  
  
  


  
  
  
  
  

  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#add_questions-instance_method" title="#add_questions (instance method)">- (Object) <strong>add_questions</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#clone-instance_method" title="#clone (instance method)">- (Object) <strong>clone</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#create-instance_method" title="#create (instance method)">- (Object) <strong>create</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#destroy-instance_method" title="#destroy (instance method)">- (Object) <strong>destroy</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#edit-instance_method" title="#edit (instance method)">- (Object) <strong>edit</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#index-instance_method" title="#index (instance method)">- (Object) <strong>index</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#new-instance_method" title="#new (instance method)">- (Object) <strong>new</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#publish-instance_method" title="#publish (instance method)">- (Object) <strong>publish</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#remove_questions-instance_method" title="#remove_questions (instance method)">- (Object) <strong>remove_questions</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#show-instance_method" title="#show (instance method)">- (Object) <strong>show</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#update-instance_method" title="#update (instance method)">- (Object) <strong>update</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#update_ranks-instance_method" title="#update_ranks (instance method)">- (Object) <strong>update_ranks</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
    </ul>
  


  
  
  
  
  
  
  

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="add_questions-instance_method">
  
    - (<tt>Object</tt>) <strong>add_questions</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 57</span>

<span class='def def kw'>def</span> <span class='add_questions identifier id'>add_questions</span>
  <span class='comment val'># load the form</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  
  <span class='comment val'># load the question objects</span>
  <span class='questions identifier id'>questions</span> <span class='assign token'>=</span> <span class='load_selected_objects identifier id'>load_selected_objects</span><span class='lparen token'>(</span><span class='Question constant id'>Question</span><span class='rparen token'>)</span>

  <span class='comment val'># raise error if no valid questions (this should be impossible)</span>
  <span class='raise identifier id'>raise</span> <span class='string val'>&quot;No valid questions given.&quot;</span> <span class='if if_mod kw'>if</span> <span class='questions identifier id'>questions</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span>
  
  <span class='comment val'># add questions to form and try to save</span>
  <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='questions identifier id'>questions</span> <span class='opasgn op'>+=</span> <span class='questions identifier id'>questions</span>
  <span class='if if kw'>if</span> <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='save identifier id'>save</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='string val'>&quot;Questions added successfully&quot;</span>
  <span class='else else kw'>else</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;There was a problem adding the questions (#{@form.errors.full_messages.join(';')})&quot;</span>
  <span class='end end kw'>end</span>
  
  <span class='comment val'># redirect to form edit</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='edit_form_path identifier id'>edit_form_path</span><span class='lparen token'>(</span><span class='@form ivar id'>@form</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="clone-instance_method">
  
    - (<tt>Object</tt>) <strong>clone</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


106
107
108
109
110
111
112
113
114
115
116</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 106</span>

<span class='def def kw'>def</span> <span class='clone identifier id'>clone</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='begin begin kw'>begin</span>
    <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='duplicate identifier id'>duplicate</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;Form '#{@form.name}' cloned successfully.&quot;</span>
  <span class='rescue rescue kw'>rescue</span>
    <span class='raise identifier id'>raise</span> <span class='$! gvar id'>$!</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;There was a problem cloning the form (#{$!.to_s}).&quot;</span>
  <span class='end end kw'>end</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:index</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="create-instance_method">
  
    - (<tt>Object</tt>) <strong>create</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


118</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 118</span>

<span class='def def kw'>def</span> <span class='create identifier id'>create</span><span class='semicolon token'>;</span> <span class='crupdate identifier id'>crupdate</span> <span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="destroy-instance_method">
  
    - (<tt>Object</tt>) <strong>destroy</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39
40
41
42
43</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 39</span>

<span class='def def kw'>def</span> <span class='destroy identifier id'>destroy</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='begin begin kw'>begin</span> <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='destroy identifier id'>destroy</span> <span class='andop op'>&amp;&amp;</span> <span class='string val'>&quot;Form deleted successfully.&quot;</span> <span class='rescue rescue kw'>rescue</span> <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='$! gvar id'>$!</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='end end kw'>end</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:index</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="edit-instance_method">
  
    - (<tt>Object</tt>) <strong>edit</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32
33</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 30</span>

<span class='def def kw'>def</span> <span class='edit identifier id'>edit</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='render_and_setup identifier id'>render_and_setup</span><span class='lparen token'>(</span><span class='string val'>&quot;update&quot;</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="index-instance_method">
  
    - (<tt>Object</tt>) <strong>index</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


18
19
20
21
22
23
24
25</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 18</span>

<span class='def def kw'>def</span> <span class='index identifier id'>index</span>
  <span class='if if kw'>if</span> <span class='request identifier id'>request</span><span class='dot token'>.</span><span class='format identifier id'>format</span><span class='dot token'>.</span><span class='xml? fid id'>xml?</span>
    <span class='@forms ivar id'>@forms</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='sorted identifier id'>sorted</span><span class='lparen token'>(</span><span class='symbol val'>:conditions</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;forms.published = 1&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:include</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:type</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='else else kw'>else</span>
    <span class='@forms ivar id'>@forms</span> <span class='assign token'>=</span> <span class='load_objects_with_subindex identifier id'>load_objects_with_subindex</span><span class='lparen token'>(</span><span class='Form constant id'>Form</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
  <span class='render_appropriate_format identifier id'>render_appropriate_format</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="new-instance_method">
  
    - (<tt>Object</tt>) <strong>new</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


26
27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 26</span>

<span class='def def kw'>def</span> <span class='new identifier id'>new</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
  <span class='render_and_setup identifier id'>render_and_setup</span><span class='lparen token'>(</span><span class='string val'>&quot;create&quot;</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="publish-instance_method">
  
    - (<tt>Object</tt>) <strong>publish</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


44
45
46
47
48
49
50
51
52
53
54
55
56</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 44</span>

<span class='def def kw'>def</span> <span class='publish identifier id'>publish</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='verb identifier id'>verb</span> <span class='assign token'>=</span> <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='published? fid id'>published?</span> <span class='integer val'>? </span><span class='string val'>&quot;unpublish&quot;</span> <span class='colon op'>:</span> <span class='string val'>&quot;publish&quot;</span>
  <span class='begin begin kw'>begin</span>
    <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='toggle_published identifier id'>toggle_published</span>
    <span class='dl identifier id'>dl</span> <span class='assign token'>=</span> <span class='verb identifier id'>verb</span> <span class='eq op'>==</span> <span class='string val'>&quot;unpublish&quot;</span> <span class='question op'>?</span> <span class='string val'>&quot; The download count has also been reset.&quot;</span> <span class='colon op'>:</span> <span class='string val'>&quot;&quot;</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;Form #{verb}ed successfully.&quot;</span> <span class='plus op'>+</span> <span class='dl identifier id'>dl</span>
  <span class='rescue rescue kw'>rescue</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;There was a problem #{verb}ing the form (#{$!.to_s}).&quot;</span>
  <span class='end end kw'>end</span>
  <span class='comment val'># redirect to form edit</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:index</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="remove_questions-instance_method">
  
    - (<tt>Object</tt>) <strong>remove_questions</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 78</span>

<span class='def def kw'>def</span> <span class='remove_questions identifier id'>remove_questions</span>
  <span class='comment val'># load the form</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='comment val'># get the selected questionings</span>
  <span class='qings identifier id'>qings</span> <span class='assign token'>=</span> <span class='load_selected_objects identifier id'>load_selected_objects</span><span class='lparen token'>(</span><span class='Questioning constant id'>Questioning</span><span class='rparen token'>)</span>
  <span class='comment val'># destroy</span>
  <span class='begin begin kw'>begin</span>
    <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='destroy_questionings identifier id'>destroy_questionings</span><span class='lparen token'>(</span><span class='qings identifier id'>qings</span><span class='rparen token'>)</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='string val'>&quot;Questions removed successfully.&quot;</span>
  <span class='rescue rescue kw'>rescue</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;There was a problem removing the questions (#{$!.to_s}).&quot;</span>
  <span class='end end kw'>end</span>
  <span class='comment val'># redirect to form edit</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='edit_form_path identifier id'>edit_form_path</span><span class='lparen token'>(</span><span class='@form ivar id'>@form</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="show-instance_method">
  
    - (<tt>Object</tt>) <strong>show</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


34
35
36
37
38</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 34</span>

<span class='def def kw'>def</span> <span class='show identifier id'>show</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find_eager identifier id'>find_eager</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='add_download identifier id'>add_download</span> <span class='if if_mod kw'>if</span> <span class='request identifier id'>request</span><span class='dot token'>.</span><span class='format identifier id'>format</span><span class='dot token'>.</span><span class='xml? fid id'>xml?</span> 
  <span class='render_appropriate_format identifier id'>render_appropriate_format</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="update-instance_method">
  
    - (<tt>Object</tt>) <strong>update</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


119</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 119</span>

<span class='def def kw'>def</span> <span class='update identifier id'>update</span><span class='semicolon token'>;</span> <span class='crupdate identifier id'>crupdate</span> <span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="update_ranks-instance_method">
  
    - (<tt>Object</tt>) <strong>update_ranks</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


93
94
95
96
97
98
99
100
101
102
103
104
105</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/controllers/forms_controller.rb', line 93</span>

<span class='def def kw'>def</span> <span class='update_ranks identifier id'>update_ranks</span>
  <span class='@form ivar id'>@form</span> <span class='assign token'>=</span> <span class='Form constant id'>Form</span><span class='dot token'>.</span><span class='find identifier id'>find</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:include</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:questionings</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:condition</span><span class='rbrace token'>}</span><span class='rparen token'>)</span>
  <span class='begin begin kw'>begin</span>
    <span class='comment val'># build hash of questioning ids to ranks</span>
    <span class='new_ranks identifier id'>new_ranks</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='semicolon token'>;</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:rank</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='each_pair identifier id'>each_pair</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='id identifier id'>id</span><span class='comma token'>,</span> <span class='rank identifier id'>rank</span><span class='bitor op'>|</span> <span class='new_ranks identifier id'>new_ranks</span><span class='lbrack token'>[</span><span class='id identifier id'>id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='rank identifier id'>rank</span><span class='rbrace token'>}</span>
    <span class='comment val'># update</span>
    <span class='@form ivar id'>@form</span><span class='dot token'>.</span><span class='update_ranks identifier id'>update_ranks</span><span class='lparen token'>(</span><span class='new_ranks identifier id'>new_ranks</span><span class='rparen token'>)</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:success</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='string val'>&quot;Ranks updated successfully.&quot;</span>
  <span class='rescue rescue kw'>rescue</span>
    <span class='flash identifier id'>flash</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;There was a problem updating the ranks (#{$!.to_s}).&quot;</span>
  <span class='end end kw'>end</span>
  <span class='redirect_to identifier id'>redirect_to</span><span class='lparen token'>(</span><span class='edit_form_path identifier id'>edit_form_path</span><span class='lparen token'>(</span><span class='@form ivar id'>@form</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Thu Dec  8 13:43:17 2011 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.3 (ruby-1.8.7).
</div>

  </body>
</html>